# Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

OHOS_BUILD_HOME=${1}
KERNEL_SRC_TMP_PATH=${2}
DEVICE_NAME=${3}

NEWIP_PATCH_FILE=${OHOS_BUILD_HOME}/kernel/linux/common_modules/newip/apply_newip.sh
# XPM_PATCH_FILE=${OHOS_BUILD_HOME}/kernel/linux/common_modules/xpm/apply_xpm.sh
QOS_AUTH_PATCH_FILE=${OHOS_BUILD_HOME}/kernel/linux/common_modules/qos_auth/apply_qos_auth.sh

debug_flag=-x
set +e
pushd ${OHOS_BUILD_HOME}
#newip
if [ -f $NEWIP_PATCH_FILE ]; then
    bash ${debug_flag} $NEWIP_PATCH_FILE ${OHOS_BUILD_HOME} ${KERNEL_SRC_TMP_PATH} ${DEVICE_NAME} linux-5.10
fi
# xpm
# if [ -f $XPM_PATCH_FILE ]; then
#     bash ${debug_flag} $XPM_PATCH_FILE ${OHOS_BUILD_HOME} ${KERNEL_SRC_TMP_PATH} ${DEVICE_NAME} linux-5.10
# fi
#qos_auth
if [ -f $QOS_AUTH_PATCH_FILE ]; then
    bash ${debug_flag} $QOS_AUTH_PATCH_FILE ${OHOS_BUILD_HOME} ${KERNEL_SRC_TMP_PATH} ${DEVICE_NAME} linux-5.10
fi

popd
set -e
